<?php 
class ControllerMessageArticle extends Controller {
	public function index() {  
		$this->language->load('message/article');

		$this->load->model('message/article');

		$this->data['breadcrumbs'] = array();

		$this->data['breadcrumbs'][] = array(
			'text'      => $this->language->get('text_home'),
			'href'      => $this->url->link('common/home'),
			'separator' => false
		);

		if (isset($this->request->get['article_id'])) {
			$article_id = (int)$this->request->get['article_id'];
		} else {
			$article_id = null;
		}
		
		
		if (isset($this->request->get['code'])) {
			$code = $this->request->get['code'];
		} else {
			$code = null;
		}
		
		if (isset($this->request->get['send_name'])) {
			$send_name =$this->request->get['send_name'];
		} else {
			$send_name = '';
		}
		
		$data = array(
			"article_id"=>$article_id,
			"code"=>$code
		);
		
		
		$this->data['send_name'] = $send_name;
		$this->data['toPosition'] = $this->url->link('message/position','send_name='.$send_name,'SSL');

		$article_info = $this->model_message_article->getArticle($data);

		if ($article_info) {
			$this->document->setTitle($article_info['title']);

			$this->data['breadcrumbs'][] = array(
				'text'      => $article_info['title'],
				'href'      => $this->url->link('message/article', 'article_id=' .  $article_id),      		
				'separator' => $this->language->get('text_separator')
			);

			$this->data['heading_title'] = $article_info['title'];

			$this->data['button_continue'] = $this->language->get('button_continue');

			$this->data['description'] = html_entity_decode($article_info['description'], ENT_QUOTES, 'UTF-8');

			$this->data['continue'] = $this->url->link('common/home');

			
		} else {
			$this->data['heading_title'] = '';
			$this->data['description'] = '没有相关信息';
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/message/article.tpl')) {
				$this->template = $this->config->get('config_template') . '/template/message/article.tpl';
			} else {
				$this->template = 'default/template/message/article.tpl';
			}

			$this->children = array(
				'common/column_left',
				'common/column_right',
				'common/content_top',
				'common/content_bottom',
				'common/footer',
				'common/header'
			);

			$this->response->setOutput($this->render());
	}

	public function info() {
		$this->load->model('catalog/information');

		if (isset($this->request->get['information_id'])) {
			$information_id = (int)$this->request->get['information_id'];
		} else {
			$information_id = 0;
		}      

		$information_info = $this->model_catalog_information->getInformation($information_id);

		if ($information_info) {
			$output  = '<html dir="ltr" lang="en">' . "\n";
			$output .= '<head>' . "\n";
			$output .= '  <title>' . $information_info['title'] . '</title>' . "\n";
			$output .= '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
			$output .= '  <meta name="robots" content="noindex">' . "\n";
			$output .= '</head>' . "\n";
			$output .= '<body>' . "\n";
			$output .= '  <h1>' . $information_info['title'] . '</h1>' . "\n";
			$output .= html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8') . "\n";
			$output .= '  </body>' . "\n";
			$output .= '</html>' . "\n";			

			$this->response->setOutput($output);
		}
	}
}
?>